// Fill out your copyright notice in the Description page of Project Settings.


#include "UI/OnlineUI.h"

#include "Components/Button.h"
#include "SoulGameplay/SoulKnightPlayerController.h"
#include "UI/MainHUD.h"
#include "UI/MainUI.h"

void UOnlineUI::NativeConstruct()
{
	Super::NativeConstruct();
	BackButton->OnClicked.AddDynamic(this, &UOnlineUI::Back);
}

void UOnlineUI::Back()
{
	if (ASoulKnightPlayerController* SoulKnightPlayerController = Cast<ASoulKnightPlayerController>(GEngine->GetFirstLocalPlayerController(GetWorld())))
	{
		if (AMainHUD* MainHUD = Cast<AMainHUD>(SoulKnightPlayerController->GetHUD()))
		{
			if (MainHUD->OnlineUI)
			{
				MainHUD->OnlineUI->RemoveFromViewport();
			}
			if (MainHUD->MainUI)
			{
				MainHUD->MainUI->AddToViewport();
			}
		}
	}
}

void UOnlineUI::PlayShowAnimation()
{
	if (ShowAnimation)
	{
		PlayAnimation(ShowAnimation);
	}
}
